package com.huluobo.kotlindemoim1911a2.widget

import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.widget.RelativeLayout
import com.huluobo.kotlindemoim1911a2.R
import com.huluobo.kotlindemoim1911a2.data.ContactListItem
import kotlinx.android.synthetic.main.view_contact_item.view.*

/**
 * Created by lc on 2022/10/21.
 */
class ContactListItemView(context: Context?, attributeSet: AttributeSet? = null) :
    RelativeLayout(context, attributeSet) {

    fun bindView(contactListItem: ContactListItem) {
        userName.text = contactListItem.userName
        if (contactListItem.showFirstLetter) {
            firstLetter.visibility = View.VISIBLE
            firstLetter.text = contactListItem.firstLetter.toString()
        } else firstLetter.visibility = View.GONE
    }

    init {
        View.inflate(context, R.layout.view_contact_item, this)//给当前自定义的RelativeLayout传递一个布局
    }
}